package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.CellRendererPane;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.table.DefaultTableCellRenderer;


import controller.ConsSituacaoContr;

import classes.Globals;
import classes.TbmSituacao;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class pnlConsSituacaoFabrica extends javax.swing.JPanel {
//   private JPanel pnlConsSituacaoFabricaTitle;
//	private JPanel jPanel1;
	private JComboBox cmbMaquina;
	private JLabel Maquina;
	private JTable TBmaq;
	private JScrollPane ScrMaquina;
	private TbmSituacao tbmSit = new TbmSituacao();
	private JPanel pnlFabrica; 	
	private ConsSituacaoContr controller = new ConsSituacaoContr(this);
	
	
	public pnlConsSituacaoFabrica() {
		super();
		initGUI();
		
		this.setBounds(0, 0, 1000, 700);
		this.setVisible(true);	
		//controller.PreencherTabela();
		
	}
	
	public TbmSituacao getTbmSit() {
		return tbmSit;
	}
	

	public JComboBox getcmbMaquina() {
		return cmbMaquina;
	}
	
	public JPanel getPnlFabrica() {
		return pnlFabrica;
	}
	

	private void initGUI() {
		try {
			
			CriarPnlFabrica();
			
			
			this.setPreferredSize(new java.awt.Dimension(804, 457));
			this.setLayout(null);
			{
				
				
				ComboBoxModel cmbMaquinaModel = new DefaultComboBoxModel(controller.ListMachine().toArray());
				
				cmbMaquina = new JComboBox();
				this.add(cmbMaquina);
				cmbMaquina.setModel(cmbMaquinaModel);
				cmbMaquina.setBounds(24, 45, 128, 23);
//				----------------------------------------------------------
				cmbMaquina.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
				tbmSit.ClearTable();
						controller.PreencherTabela();
					
					}
				});
			}
			{
				Maquina = new JLabel();
				this.add(Maquina);
				Maquina.setText("Maquina");
				Maquina.setBounds(24, 17, 72, 16);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		
		}
	

	
	}
	private void CriarPnlFabrica() {
		TBmaq   	  = new JTable(tbmSit);
		ScrMaquina		  = new JScrollPane(TBmaq);
		
		this.add(ScrMaquina);
	
	
		ScrMaquina.setBounds(24, 86, 960, 400);

		TBmaq.setBorder(BorderFactory.createEtchedBorder());
		TBmaq.getTableHeader().setBackground(new Color(213,213,255));
		TBmaq.getTableHeader().setForeground(Color.BLACK);
		TBmaq.setRowHeight(20);
		
		TBmaq.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		TBmaq.getTableHeader().setResizingAllowed(false);
		
		TBmaq.getColumnModel().getColumn(0).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.10f));
		TBmaq.getColumnModel().getColumn(1).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.10f));
		TBmaq.getColumnModel().getColumn(2).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.15f));
		TBmaq.getColumnModel().getColumn(3).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.10f));
		TBmaq.getColumnModel().getColumn(4).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.15f));
		TBmaq.getColumnModel().getColumn(5).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.15f));
		TBmaq.getColumnModel().getColumn(6).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.1f));
		TBmaq.getColumnModel().getColumn(6).setPreferredWidth((int)(ScrMaquina.getBounds().width * 0.18f));
		TBmaq.setVisible(true);
		TBmaq.setVisible(true);
		
		
		
		
		
	}
	
}


